package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.RecDispatchCarEntity;
import com.jinmdz.fmis.mapper.mapper.provider.RecDispatchCarProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 车辆调度表Mapper
 *
 * @author generator
 * @date 2020-07-06 17:23
 */
public interface RecDispatchCarMapper {

    /**
     * 增加RecDispatchCar
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-07-06 17:23
     */
    @InsertProvider(type = RecDispatchCarProvider.class, method = "insertRecDispatchCar")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertRecDispatchCar(@Param("entity") RecDispatchCarEntity entity);

    /**
     * 删除RecDispatchCar
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-07-06 17:23
     */
    @Update(" update rec_dispatch_car set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForRecDispatchCar(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改RecDispatchCar
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-07-06 17:23
     */
    @UpdateProvider(type = RecDispatchCarProvider.class, method = "updateRecDispatchCar")
    void updateRecDispatchCar(@Param("entity") RecDispatchCarEntity entity);

    /**
     * 查询RecDispatchCar实体
     *
     * @param id 主键
     * @return RecDispatchCarEntity
     * @author generator
     * @date 2020-07-06 17:23
     */
    @Select(" select id,deleted,rec_id,rec_car_id,rec_car_no,dispatch_user_name,dispatch_user_id,dispatch_out_time,dispatch_back_time,dispatch_time,odometer,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from rec_dispatch_car where id = #{id} and deleted = 0 limit 1 ")
    RecDispatchCarEntity getRecDispatchCarById(@Param("id") Integer id);

    /**
     * 查询RecDispatchCar列表
     *
     * @param entity 数据实体
     * @return RecDispatchCarEntity
     * @author generator
     * @date 2020-07-06 17:23
     */
    @SelectProvider(type = RecDispatchCarProvider.class, method = "listRecDispatchCar")
    ArrayList<RecDispatchCarEntity> listRecDispatchCar(@Param("entity") RecDispatchCarEntity entity);
}